package com.xquant.transaction_management_system.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xquant.transaction_management_system.mapper.FinancialInstrumentsValuationMapper;
import com.xquant.transaction_management_system.mapper.TransactionMapper;
import com.xquant.transaction_management_system.model.PO.FinancialInstrumentsValuation;
import com.xquant.transaction_management_system.model.PO.Transaction;
import com.xquant.transaction_management_system.model.VO.SearchValvationVo;
import com.xquant.transaction_management_system.service.FinancialInstrumentsValuationService;
import com.xquant.transaction_management_system.service.TransactionService;
import org.springframework.stereotype.Service;

@Service
public class FinancialInstrumentsValuationServiceImpl extends ServiceImpl<FinancialInstrumentsValuationMapper, FinancialInstrumentsValuation> implements FinancialInstrumentsValuationService {
    @Override
    public IPage<FinancialInstrumentsValuation> selectByPage(Page<FinancialInstrumentsValuation> pageParam, SearchValvationVo searchValvationVo) {

        QueryWrapper<FinancialInstrumentsValuation> queryWrapper = new QueryWrapper<>();
        if (searchValvationVo.getDebentureCode()!=null){
            queryWrapper.like("debenture_code",searchValvationVo.getDebentureCode());
        }
        if (searchValvationVo.getDebentureName()!=null){
            queryWrapper.like("debenture_name",searchValvationVo.getDebentureName());
        }
        if (searchValvationVo.getValueDate()!=null){
            queryWrapper.eq("value_date",searchValvationVo.getValueDate());
        }
        IPage<FinancialInstrumentsValuation> selectPage = baseMapper.selectPage(pageParam, queryWrapper);
        return selectPage;
    }

    @Override
    public IPage<FinancialInstrumentsValuation> selectByPages(Page<FinancialInstrumentsValuation> pageParam) {
        QueryWrapper<FinancialInstrumentsValuation> queryWrapper = new QueryWrapper<>();
        IPage<FinancialInstrumentsValuation> selectPage = baseMapper.selectPage(pageParam, queryWrapper);
        return selectPage;
    }
}
